package com.example.dao;

import com.alibaba.druid.pool.DruidDataSourceFactory;

import javax.sql.DataSource;
import java.util.HashMap;
import java.util.Map;

public class DataBaseUtils {
    public static DataSource getDataSource()  {
        Map<String, String> druidMap=new HashMap<String, String>();
        druidMap.put(DruidDataSourceFactory.PROP_USERNAME, "root");
        druidMap.put(DruidDataSourceFactory.PROP_PASSWORD, "root");
        druidMap.put(DruidDataSourceFactory.PROP_URL, "jdbc:mysql://127.0.0.1:3306/gym_management");
        druidMap.put(DruidDataSourceFactory.PROP_DRIVERCLASSNAME, "com.mysql.jdbc.Driver");
        try {
            return DruidDataSourceFactory.createDataSource(druidMap);
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }

    }

}
